<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '游戏资讯';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="mobi-news-index">

    <h1><?= Html::encode($this->title) ?></h1>

    <p>
        <?= Html::a('添加新闻', ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'id',
            'title',
            'auth',
            [
                'attribute'=>'content',
                'format' => ['raw',],
                'value' => function($model){
                    return mb_substr(strip_tags($model->content), 0, 80).'...';
                }
            ],
            'created_at',
            'updated_at',
            // 'created_by',
            // 'updated_by',

            [
                'class' => 'yii\grid\ActionColumn',
                'header' => '操作',
                'template' => '{view}{update}{delete}',
                'buttons' => [
                    'view' => function ($url, $model, $key) {
                        return Html::a(' 查看 ', "/news/$model->id", ['title' => '查看前台展示效果', 'target' => '__black'] );
                    },
                    'update' => function ($url, $model, $key) {
                        return Html::a(' 编辑 ', $url, ['title' => '文章编辑'] );
                    },
                ],
            ],
        ],
    ]); ?>
</div>
